package internationalization;

import enums.URLEnum;
import misc.BundlesProvider;

import javax.swing.*;
import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * Esta clase posee metodos estaticos que fuerzan los terminos propios de un idioma al FilechooserBundle,
 * logrando la correcta internacionalizacion;
 *
 * @author Jose Martin Rozanec;
 */
public class Internationalizer {
    /**
     * Sets spanish internationalization variables to filechooser and other components that
     * does not change automatically while changing the Locale;
     */
    public static void setSpanish() {
        Locale spanishLocale = new Locale("es");
        Locale.setDefault(spanishLocale);
        //The following code is used to provide spanish internationalization for filechoosers...
        System.out.println("");
        ResourceBundle fileChooserBundle = BundlesProvider.getBundle(URLEnum.FILECHOOSER_BUNDLE);
        Enumeration<String> keyEn;
        keyEn = fileChooserBundle.getKeys();
        while (keyEn.hasMoreElements()) {
            String key = keyEn.nextElement();
            UIManager.put(key, fileChooserBundle.getString(key));
        }
        //End of filechooser internationalization...

        //the following internationalizes the JOptionPane
        //UPDATE: the options[] allows to set any kind of text there!
        //end of OptionPane internationalization
    }
}
